<template>
	<view class="content">
		<view v-for="(item,index) in CourseInfoSignList" :key="index">
			<view v-if="item.isSign">
				<u-card :title="item.isSign.title" padding="30" margin="26rpx">
					<view slot="body" style="display: flex;align-items: center;justify-content: space-between;">
						<view class="u-body-item-title u-line-2">签到地址：{{ item.isSign.signInAddress }}</view>
					</view>
					<view slot="foot">
						<view class="u-body-item-title u-line-2">签到时间：{{ item.isSign.signInTime }}</view>
					</view>
				</u-card>
			</view>
			<view v-else>
				<u-card :title="item.title" padding="30" margin="26rpx">
					<view slot="body" style="display: flex;align-items: center;justify-content: space-between;">
						<view class="u-body-item-title u-line-2">未签到</view>
					</view>
					<view slot="foot">
						<view class="u-body-item-title u-line-2">上课时间：{{ item.attendClassTime }}</view>
					</view>
				</u-card>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		getSignByStudentId,
		getCourseInfoSignByStudentId
	} from '@/api/jz/sign/info.js'
	import {
		getInfoId
	} from '@/utils/auth';

	export default {
		data() {
			return {
				mySignInList: [],
				CourseInfoSignList: [],
				student: null
			}
		},
		onLoad(data) {
			if (data.data) {
				this.student = JSON.parse(decodeURIComponent(data.data))
			}

		},
		methods: {
			getMySign() {
				getSignByStudentId().then((res) => {
					if (res.code == 200) {
						this.mySignInList = res.data
					}
				})
			},
			getCourseInfoSignByStudentIdFun() {
				let studentId = null;
				if (this.student) {
					studentId = this.student.id
				} else {
					studentId = getInfoId();
				}
				getCourseInfoSignByStudentId(studentId).then((res) => {
					if (res.code == 200) {

						for (var i = 0; i < res.data.length; i++) {
							if (res.data[i].professorName) {
								res.data[i].title = res.data[i].title + '(' + res.data[i].professorName + ')'
							}

						}
						this.CourseInfoSignList = res.data
					}
				})
			}
		},
		mounted() {
			// this.getMySign();
			this.getCourseInfoSignByStudentIdFun();
		}
	}
</script>

<style>
</style>